export const formatTime = (date, months) => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  let dates = ''
  if (months) {
    dates = [year, month].map(formatNumber).join('-')
  } else {
    dates = [year, month, day].map(formatNumber).join('-')
  }
  return (
    dates
    
    // ' ' +
    // [hour, minute, second].map(formatNumber).join(':')
  )
}

const formatNumber = (n) => {
  const s = n.toString()
  return s[1] ? s : '0' + s
}
export const getTime = (dateTimeString) => {
  // 将字符串分割成日期和时间部分
  const [datePart, timePart] = dateTimeString.split(' ');

  // 从日期部分中去掉年份
  const dateWithoutYear = datePart.slice(5);

  // 从时间部分中去掉秒数
  const timeWithoutSeconds = timePart.slice(0, -3);

  // 合并日期和时间部分
  const result = `${dateWithoutYear} ${timeWithoutSeconds}`;

  return result
}